//
//  RemindView.m
//  FaceSDKSample_IOS
//
//  Created by Tong,Shasha on 2017/9/5.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import "BDFaceRemindView.h"

@implementation BDFaceRemindView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.borderWidth = 1.0;
        self.layer.borderColor = OutSideColor.CGColor;
        self.layer.cornerRadius = 17;
        
        UIImageView * remindImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, (frame.size.height-27)/2.0, 27, 27)];
        remindImage.image = [self getImageResourceForName:@"warning"];
        [self addSubview:remindImage];
        
        UILabel * remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(remindImage.frame)+15, CGRectGetMinY(remindImage.frame), 120, CGRectGetHeight(remindImage.frame))];
        remindLabel.textColor = OutSideColor;
        remindLabel.font = [UIFont systemFontOfSize:22];
        remindLabel.text = @"请正对手机";
        [self addSubview:remindLabel];
    }
    return self;
}

- (UIImage *)getImageResourceForName:(NSString *)name {
    NSString* bundlepath = [[NSBundle mainBundle] pathForResource:@"com.baidu.idl.face.faceSDK.bundle" ofType:nil];
    NSBundle* modelBundle = [NSBundle bundleWithPath:bundlepath];
    NSString* imagePath = [modelBundle pathForResource:name ofType:@"png"];
    return [[UIImage alloc] initWithContentsOfFile:imagePath];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
